home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1998 #1 / Amiga Plus 1998 #1.iso / demo-versionen / haage&partner / warpup-warpos / include / powerpc / ppcmacros.i < prev    next >
Text File  |  1997-09-24  |  15KB  |  521 lines

  1.                 IFND    POWERPC_PPCMACROS_I
  2. POWERPC_PPCMACROS_I     set     1
  3.  
  4. **
  5. **      $VER: PPCmacros.i 8.0 (3.6.97)
  6. **
  7. **      WarpOS Release 1.0
  8. **
  9. **      '(C) Copyright 1997 Haage & Partner Computer GmbH'
  10. **      All Rights Reserved
  11. **
  12. **      standard macros and definitions for PowerPC
  13. **
  14.  
  15. BITDEFPPC       macro
  16. \1P_\2          =       \3
  17. \1B_\2          =       31-(\3)
  18. \1F_\2          =       1<<(31-(\3))
  19.                 endm
  20.  
  21. ALLOCPPCMEM     macro
  22.                 movem.l d1/a0/a1/a6,-(sp)
  23.                 move.l  _SysBase,a6
  24.                 add.l   #56,d0
  25.                 jsr     -684(a6)                ;AllocVec
  26.                 move.l  d0,d1
  27.                 beq     .zero\@
  28.                 add.l   #39,d0
  29.                 and.l   #$ffffffe0,d0
  30.                 move.l  d0,a0
  31.                 move.l  d1,-4(a0)
  32. .zero\@
  33.                 movem.l (sp)+,d1/a0/a1/a6
  34.                 endm
  35.  
  36. FREEPPCMEM      macro
  37.                 movem.l d0/d1/a0/a1/a6,-(sp)
  38.                 move.l  a1,d0
  39.                 beq.b   .nofree\@
  40.                 move.l  -4(a1),a1
  41.                 move.l  _SysBase,a6
  42.                 jsr     -690(a6)                ;FreeVec
  43. .nofree\@
  44.                 movem.l (sp)+,d0/d1/a0/a1/a6
  45.                 endm
  46.  
  47.                 IFD     _POWERMODE
  48.  
  49.                 IFND    __LOCALSIZE
  50. __LOCALSIZE     set     256
  51.                 ENDC
  52.                 IFND    local
  53. __LOCAL         setr    r13
  54. local           setr    r13
  55.                 ENDC
  56. base            equr    r2
  57. stack           equr    r1
  58. trash           equr    r0
  59.  
  60. **** these register symbols can be used when transferring parameters from
  61. **** 68K to PPC and vice versa
  62.  
  63. _d0             equr    r3
  64. _d1             equr    r4
  65. _d2             equr    r22
  66. _d3             equr    r23
  67. _d4             equr    r24
  68. _d5             equr    r25
  69. _d6             equr    r26
  70. _d7             equr    r27
  71. _a0             equr    r5
  72. _a1             equr    r6
  73. _a2             equr    r28
  74. _a3             equr    r29
  75. _a4             equr    base
  76. _a5             equr    r30
  77. _a6             equr    r31
  78.  
  79. _fp0            fequr   f1
  80. _fp1            fequr   f2
  81. _fp2            fequr   f3
  82. _fp3            fequr   f4
  83. _fp4            fequr   f5
  84. _fp5            fequr   f6
  85. _fp6            fequr   f7
  86. _fp7            fequr   f8
  87.  
  88. lw              macro
  89.                         IFEQ    __MODE-__NEAR
  90.                                 lwz     \1,\2(base)
  91.                         ELSEIF
  92.                                 la      \1,\2
  93.                                 lwz     \1,0(\1)
  94.                         ENDC
  95.                 endm
  96.  
  97. lh              macro
  98.                         IFEQ    __MODE-__NEAR
  99.                                 lhz     \1,\2(base)
  100.                         ELSEIF
  101.                                 la      \1,\2
  102.                                 lhz     \1,0(\1)
  103.                         ENDC
  104.                 endm
  105.  
  106. lhs             macro
  107.                         IFEQ    __MODE-__NEAR
  108.                                 lha     \1,\2(base)
  109.                         ELSEIF
  110.                                 la      \1,\2
  111.                                 lha     \1,0(\1)
  112.                         ENDC
  113.                 endm
  114.  
  115. lb              macro
  116.                         IFEQ    __MODE-__NEAR
  117.                                 lbz     \1,\2(base)
  118.                         ELSEIF
  119.                                 la      \1,\2
  120.                                 lbz     \1,0(\1)
  121.                         ENDC
  122.                 endm
  123.  
  124. lbs             macro
  125.                         IFEQ    __MODE-__NEAR
  126.                                 lbz     \1,\2(base)
  127.                                 extsb   \1,\1
  128.                         ELSEIF
  129.                                 la      \1,\2
  130.                                 lbz     \1,0(\1)
  131.                                 extsb   \1,\1
  132.                         ENDC
  133.                 endm
  134.  
  135. lf              macro
  136.                         IFEQ    __MODE-__NEAR
  137.                                 lfd     \1,\2(base)
  138.                         ELSEIF
  139.                                 mr      trash,r3
  140.                                 la      r3,\2
  141.                                 lfd     \1,0(r3)
  142.                                 mr      r3,trash
  143.                         ENDC
  144.                 endm
  145.  
  146. ls              macro
  147.                         IFEQ    __MODE-__NEAR
  148.                                 lfs     \1,\2(base)
  149.                         ELSEIF
  150.                                 mr      trash,r3
  151.                                 la      r3,\2
  152.                                 lfs     \1,0(r3)
  153.                                 mr      r3,trash
  154.                         ENDC
  155.                 endm
  156.  
  157. sw              macro
  158.                         IFEQ    __MODE-__NEAR
  159.                                 stw     \1,\2(base)
  160.                         ELSEIF
  161.                                 mr      trash,\1
  162.                                 la      \1,\2
  163.                                 stw     trash,0(\1)
  164.                                 mr      \1,trash
  165.                         ENDC
  166.                 endm
  167.  
  168. sh              macro
  169.                         IFEQ    __MODE-__NEAR
  170.                                 sth     \1,\2(base)
  171.                         ELSEIF
  172.                                 mr      trash,\1
  173.                                 la      \1,\2
  174.                                 sth     trash,0(\1)
  175.                                 mr      \1,trash
  176.                         ENDC
  177.                 endm
  178.  
  179. sb              macro
  180.                         IFEQ    __MODE-__NEAR
  181.                                 stb     \1,\2(base)
  182.                         ELSEIF
  183.                                 mr      trash,\1
  184.                                 la      \1,\2
  185.                                 stb     trash,0(\1)
  186.                                 mr      \1,trash
  187.                         ENDC
  188.                 endm
  189.  
  190. sf              macro
  191.                         IFEQ    __MODE-__NEAR
  192.                                 stfd    \1,\2(base)
  193.                         ELSEIF
  194.                                 mr      trash,r3
  195.                                 la      r3,\2
  196.                                 stfd    \1,0(r3)
  197.                                 mr      r3,trash
  198.                         ENDC
  199.                 endm
  200.  
  201. ss              macro
  202.                         IFEQ    __MODE-__NEAR
  203.                                 stfs    \1,\2(base)
  204.                         ELSEIF
  205.                                 mr      trash,r3
  206.                                 la      r3,\2
  207.                                 stfs    \1,0(r3)
  208.                                 mr      r3,trash
  209.                         ENDC
  210.                 endm
  211.  
  212. lba             macro
  213.                 lbz     \1,\2
  214.                 extsb   \1,\1
  215.                 endm
  216.  
  217. lbau            macro
  218.                 lbzu    \1,\2
  219.                 extsb   \1,\1
  220.                 endm
  221.  
  222. lbax            macro
  223.                 lbzx    \1,\2,\3
  224.                 extsb   \1,\1
  225.                 endm
  226.  
  227. lbaux           macro
  228.                 lbzux   \1,\2,\3
  229.                 extsb   \1,\1
  230.                 endm
  231.  
  232. stwi            macro
  233.                 liw     trash,\1
  234.                 stw     trash,\2
  235.                 endm
  236.  
  237. sthi            macro
  238.                 li      trash,\1
  239.                 sth     trash,\2
  240.                 endm
  241.  
  242. stbi            macro
  243.                 li      trash,\1
  244.                 stb     trash,\2
  245.                 endm
  246.  
  247. stwiu           macro
  248.                 liw     trash,\1
  249.                 stwu    trash,\2
  250.                 endm
  251.  
  252. sthiu           macro
  253.                 li      trash,\1
  254.                 sthu    trash,\2
  255.                 endm
  256.  
  257. stbiu           macro
  258.                 li      trash,\1
  259.                 stbu    trash,\2
  260.                 endm
  261.  
  262. stwix           macro
  263.                 liw     trash,\1
  264.                 stwx    trash,\2,\3
  265.                 endm
  266.  
  267. sthix           macro
  268.                 li      trash,\1
  269.                 sthx    trash,\2,\3
  270.                 endm
  271.  
  272. stbix           macro
  273.                 li      trash,\1
  274.                 stbx    trash,\2,\3
  275.                 endm
  276.  
  277. stwiux          macro
  278.                 liw     trash,\1
  279.                 stwux   trash,\2,\3
  280.                 endm
  281.  
  282. sthiux          macro
  283.                 li      trash,\1
  284.                 sthux   trash,\2,\3
  285.                 endm
  286.  
  287. stbiux          macro
  288.                 li      trash,\1
  289.                 stbux   trash,\2,\3
  290.                 endm
  291.  
  292. swi             macro
  293.                         IFEQ    __MODE-__NEAR
  294.                                 liw     trash,\1
  295.                                 stw     trash,\2(base)
  296.                         ELSEIF
  297.                                 stw     r3,-4(local)
  298.                                 liw     trash,\1
  299.                                 la      r3,\2
  300.                                 stw     trash,0(r3)
  301.                                 lwz     r3,-4(local)
  302.                         ENDC
  303.                 endm
  304.  
  305. shi             macro
  306.                         IFEQ    __MODE-__NEAR
  307.                                 li      trash,\1
  308.                                 sth     trash,\2(base)
  309.                         ELSEIF
  310.                                 stw     r3,-4(local)
  311.                                 li      trash,\1
  312.                                 la      r3,\2
  313.                                 sth     trash,0(r3)
  314.                                 lwz     r3,-4(local)
  315.                         ENDC
  316.                 endm
  317.  
  318. sbi             macro
  319.                         IFEQ    __MODE-__NEAR
  320.                                 li      trash,\1
  321.                                 stb     trash,\2(base)
  322.                         ELSEIF
  323.                                 stw     r3,-4(local)
  324.                                 li      trash,\1
  325.                                 la      r3,\2
  326.                                 stb     trash,0(r3)
  327.                                 lwz     r3,-4(local)
  328.                         ENDC
  329.                 endm
  330.  
  331. liw             macro
  332.                 lis     \1,High(\2)
  333.                 ori     \1,\1,Low(\2)
  334.                 endm
  335.  
  336. clrw            macro
  337.                 xor\0   \1,\1,\1
  338.                 endm
  339.  
  340. clrh            macro
  341.                 clrrwi\0 \1,\1,16
  342.                 endm
  343.  
  344. clrb            macro
  345.                 clrrwi\0 \1,\1,8
  346.                 endm
  347.  
  348. setb            macro
  349.                 ori     \1,\1,$ff
  350.                 endm
  351.  
  352. seth            macro
  353.                 ori     \1,\1,$ffff
  354.                 endm
  355.  
  356. setw            macro
  357.                 eqv\0   \1,\1,\1
  358.                 endm
  359.  
  360. mh              macro
  361.                 insrwi\0 \1,\2,16,16
  362.                 endm
  363.  
  364. mb              macro
  365.                 insrwi\0 \1,\2,8,24
  366.                 endm
  367.  
  368. tstb            macro
  369.                 extsb.  trash,\1
  370.                 endm
  371.  
  372. tsth            macro
  373.                 extsh.  trash,\1
  374.                 endm
  375.  
  376. tstw            macro
  377.                 mr.     \1,\1
  378.                 endm
  379.  
  380. bittst          macro
  381.                 IFLT    (\2)-31
  382.                         extrwi. trash,\1,1,\2
  383.                 ELSEIF
  384.                         andi.   trash,\1,$1
  385.                 ENDC
  386.                 endm
  387.  
  388. bitset          macro
  389.                 IFLT    (\2)-16
  390.                         oris    \1,\1,(1<<(15-(\2)))
  391.                 ELSEIF
  392.                         ori     \1,\1,(1<<(31-(\2)))
  393.                 ENDC
  394.                 endm
  395.  
  396. bitclr          macro
  397.                 IFLT    (\2)-16
  398.                         oris    \1,\1,(1<<(15-(\2)))
  399.                         xoris   \1,\1,(1<<(15-(\2)))
  400.                 ELSEIF
  401.                         ori     \1,\1,(1<<(31-(\2)))
  402.                         xori    \1,\1,(1<<(31-(\2)))
  403.                 ENDC
  404.                 endm
  405.  
  406. bitchg          macro
  407.                 IFLT    (\2)-16
  408.                         xoris   \1,\1,(1<<(15-(\2)))
  409.                 ELSEIF
  410.                         xori    \1,\1,(1<<(31-(\2)))
  411.                 ENDC
  412.                 endm
  413.  
  414. push            macro
  415.                 stwu    \1,-4(local)
  416.                 endm
  417.  
  418. pushf           macro
  419.                 stfdu   \1,-8(local)
  420.                 endm
  421.  
  422. pushlr          macro
  423.                 mflr    trash
  424.                 stwu    trash,-4(local)
  425.                 endm
  426.  
  427. pushctr         macro
  428.                 mfctr   trash
  429.                 stwu    trash,-4(local)
  430.                 endm
  431.  
  432. pushcr          macro
  433.                 mfcr    trash
  434.                 stwu    trash,-4(local)
  435.                 endm
  436.  
  437. pop             macro
  438.                 lwz     \1,0(local)
  439.                 addi    local,local,4
  440.                 endm
  441.  
  442. popf            macro
  443.                 lfd     \1,0(local)
  444.                 addi    local,local,8
  445.                 endm
  446.  
  447. poplr           macro
  448.                 lwz     trash,0(local)
  449.                 addi    local,local,4
  450.                 mtlr    trash
  451.                 endm
  452.  
  453. popctr          macro
  454.                 lwz     trash,0(local)
  455.                 addi    local,local,4
  456.                 mtctr   trash
  457.                 endm
  458.  
  459. popcr           macro
  460.                 lwz     trash,0(local)
  461.                 addi    local,local,4
  462.                 mtcr    trash
  463.                 endm
  464.  
  465. lnk             macro
  466.                 stwu    \1,-4(local)
  467.                 mr      \1,local
  468.                 addi    local,local,\2
  469.                 endm
  470.  
  471. ulnk            macro
  472.                 mr      local,\1
  473.                 lwz     \1,0(local)
  474.                 addi    local,local,4
  475.                 endm
  476.  
  477.  
  478. setlocal        macro
  479. __LOCALSIZE     set     \1
  480. __LOCAL         setr    \2
  481. local           setr    \2
  482.                 endm
  483.  
  484. prolog          macro
  485.                 IFNC    "","\2"
  486. local           setr    \2
  487. __LOCAL         setr    \2
  488.                 ENDC
  489.                 IFC     "TOC","\3"
  490.                         stw     base,20(stack)
  491.                 ENDC
  492.                 mflr    trash
  493.                 stw     trash,8(stack)
  494.                 mfcr    trash
  495.                 stw     trash,4(stack)
  496.                 stw     local,-4(stack)
  497.                 subi    local,stack,4
  498.                 IFC     "","\1"
  499.                         stwu    stack,-(24+4+__LOCALSIZE)(stack)
  500.                 ELSEIF
  501.                         stwu    stack,-(24+4+(\1))(stack)
  502.                 ENDC
  503.                 endm
  504.  
  505. epilog          macro
  506.                 lwz     stack,0(stack)
  507.                 lwz     local,-4(stack)
  508.                 lwz     trash,8(stack)
  509.                 mtlr    trash
  510.                 lwz     trash,4(stack)
  511.                 mtcr    trash
  512.                 IFC     "TOC","\1"
  513.                         lwz     base,20(stack)
  514.                 ENDC
  515.                 blr
  516.                 endm
  517.  
  518.                 ENDC
  519.  
  520.                 ENDC ; IFND PPCMACROS_I
  521.